#!/usr/bin/env python2.5
# encoding: utf-8
from Tkinter import *

class App:

    def __init__(self, master):

        self.frame = Frame(master)
        self.frame.pack()
        
        self.canvas = Canvas()
        
        self.canvas.pack()
        
        print self.canvas.keys()
        
        self.canvas['cursor'] = 'gobbler'
        
        self.canvas['bg'] = 'PeachPuff'
        
        self.canvas.bind("<Button-1>", self.make_hi)

        self.button = Button(self.frame, text="QUIT", fg="red", command=self.frame.quit)
        self.button.pack(side=LEFT)
        
        self.hi_there = Button(self.frame, text="Hi !", command=self.say_hi)
        self.hi_there.pack(side=LEFT)

        for i in range(0, 3):
            Button(self.frame, text="Hello", command=self.say_hi).pack(side=LEFT)

    def say_hi(self):
        print "hi there, everyone!"
        
        self.hi_there.destroy()
    
    def make_hi(self, event):
        print "Hi !!"
        
        self.hi_there = Button(self.frame, text="Hi !", command=self.say_hi)
        self.hi_there.pack(side=LEFT)

def callback():
    print "called the callback!"

root = Tk()

top = Toplevel()
app = App(root)

# create a menu
menu = Menu(root)
root.config(menu=menu)

filemenu = Menu(menu)
menu.add_cascade(label="File", menu=filemenu)
filemenu.add_command(label="New", command=callback)
filemenu.add_command(label="Open...", command=callback)
filemenu.add_separator()
filemenu.add_command(label="Exit", command=callback)

helpmenu = Menu(menu)
menu.add_cascade(label="Help", menu=helpmenu)
helpmenu.add_command(label="About...", command=callback)

menu2 = Menu(top)
filemenu2 = Menu(menu2)
menu.add_cascade(label="Blah")

toolbar = Frame(root)

b = Button(toolbar, text="new", width=6, command=callback)
b.pack(side=LEFT, padx=2, pady=2)

b = Button(toolbar, text="open", width=6, command=callback)
b.pack(side=LEFT, padx=2, pady=2)

toolbar.pack(side=TOP, fill=X)


root.mainloop()
